package cn.wolfcode.luowowo.ticket.service.impl;

import cn.wolfcode.luowowo.ticket.domain.PriceTicket;
import cn.wolfcode.luowowo.ticket.mapper.PriceTicketMapper;
import cn.wolfcode.luowowo.ticket.query.QueryScenic;
import cn.wolfcode.luowowo.ticket.service.IPriceTicketService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class PriceTicketServiceImpl implements IPriceTicketService {
    @Autowired
    private PriceTicketMapper priceTicketMapper;

    @Override
    public void deleteByPrimaryKey(Long id) {
        priceTicketMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void insert(PriceTicket priceTicket) {
        priceTicketMapper.insert(priceTicket);
    }

    @Override
    public PriceTicket selectByPrimaryKey(Long id) {
        PriceTicket priceTicket = priceTicketMapper.selectByPrimaryKey(id);
        return priceTicket;
    }

    @Override
    public List<PriceTicket> selectAll() {
        List<PriceTicket> priceTicketList = priceTicketMapper.selectAll();
        return priceTicketList;
    }

    @Override
    public void updateByPrimaryKey(PriceTicket priceTicket) {
        priceTicketMapper.updateByPrimaryKey(priceTicket);
    }

    @Override
    public List<PriceTicket> queryDestIdAndScenicId(Long destId, Long scenicId) {
        return priceTicketMapper.queryDestIdAndScenicId(destId, scenicId);
    }

    @Override
    public PriceTicket queryScenicId(Long scenicId) {
        return priceTicketMapper.selectByPrimaryKey(scenicId);
    }

    //查询观光景点
    @Override
    public List<PriceTicket> QueryScorerSightseeing(QueryScenic qo) {
        //因为页面有些请求不是我们设置的,所以我自己手动设置,把观关景点的查询条件设置为1,这样就能查询先对应的数据
        if (qo.getSightseeing() == null) {
            qo.setSightseeing(1);
        }
        return priceTicketMapper.QueryScorerSightseeing(qo);
    }

    @Override
    public List<PriceTicket> QueryScorerGood(QueryScenic qo) {
        if (qo.getGood() == null) {
            qo.setGood(1);
        }
        return priceTicketMapper.QueryScorerGood(qo);
    }

    @Override
    public List<PriceTicket> selectStateAll() {
        List<PriceTicket> priceTickets = priceTicketMapper.selectStateAll();
        if (priceTickets.size() > 4) {
            List<PriceTicket> subList = priceTickets.subList(0, 4);
            return subList;
        }
        return priceTicketMapper.selectStateAll();
    }

    @Override
    public List<PriceTicket> queryDestId(Long ajaxDestId) {
        return priceTicketMapper.queryDestId(ajaxDestId);
    }
//
//    @Override
//    public List<PriceTicket> selectScenicId(Long scenicId) {
//        return priceTicketMapper.selectScenicId(scenicId);
//    }

}
